<!DOCTYPE html>
<html lang="en">
<head>
    <title>eStore管理系统</title>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="${request.contextPath}/css/bootstrap.min.css" />
    <link rel="stylesheet" href="${request.contextPath}/css/bootstrap-responsive.min.css" />
    <link rel="stylesheet" href="${request.contextPath}/css/fullcalendar.css" />
    <link rel="stylesheet" href="${request.contextPath}/css/matrix-style.css" />
    <link rel="stylesheet" href="${request.contextPath}/css/matrix-media.css" />
    <link href="${request.contextPath}/css/font-awesome.css" rel="stylesheet" />
    <link rel="stylesheet" href="${request.contextPath}/css/jquery.gritter.css" />
    <link rel="stylesheet" href="${request.contextPath}/css/sweetalert.css" />
    <link rel="stylesheet" href="${request.contextPath}/css/google.css" />
    <link rel="stylesheet" href="${request.contextPath}/css/select2.css" />
    <link rel="stylesheet" href="${request.contextPath}/css/select2.min.css" />
</head>
<body>

<!--Header-part-->
<div id="header">
    <h1><a href="${request.contextPath}">eStore</a></h1>
</div>
<!--close-Header-part-->


<!--top-Header-menu-->
<div id="user-nav" class="navbar navbar-inverse">
    <ul class="nav">
        <li class=""><a title="" href="#"><i class="icon icon-user"></i> <span class="text">欢迎登录, ${account.accountName}</span></a></li>
        <li class=""><a title="" href="${request.contextPath}/account/to-changePassword" id="btn_changePassword"><i class="icon icon-cog"></i> <span class="text">重置密码</span></a></li>
        <li class=""><a title="" href="${request.contextPath}/account/logout"><i class="icon icon-share-alt"></i> <span class="text">退出登录</span></a></li>
    </ul>
</div>
<!--close-top-Header-menu-->
<!--start-top-serch-->
<!--<div id="search">-->
<!--<input type="text" placeholder="Search here..."/>-->
<!--<button type="submit" class="tip-bottom" title="Search"><i class="icon-search icon-white"></i></button>-->
<!--</div>-->
<!--close-top-serch-->
<!--sidebar-menu-->
<div id="sidebar"><a href="#" class="visible-phone"><i class="icon icon-home"></i> Dashboard</a>
    <ul>
        <li><a href="${request.contextPath}/account/index"><i class="icon icon-home"></i> <span>控制台</span></a> </li>
        <li class="submenu"><a href="#"><i class="icon icon-user"></i> <span>会员管理</span></a>
            <ul>
                <li><a href="${request.contextPath}/member/memberList" class="sub_menu">会员信息</a></li>
                <li><a href="${request.contextPath}/member/level/list" class="sub_menu">会员等级</a></li>
            </ul>
        </li>
        <li class="submenu"><a href="#"><i class="icon icon-th"></i> <span>商品管理</span></a>
            <ul>
                <li><a href="${request.contextPath}/product/infoList" class="sub_menu">商品信息</a></li>
                <li><a href="${request.contextPath}/product/specList" class="sub_menu">商品规格</a></li>
            </ul>
        </li>
        <li class="submenu"><a href="#"><i class="icon icon-th"></i> <span>商品库存管理</span></a>
            <ul>
                <li><a href="${request.contextPath}/stock/list" class="sub_menu">商品入库</a></li>
                <li><a href="${request.contextPath}/sale/order/list" class="sub_menu">商品销售</a></li>
            </ul>
        </li>
        <li class="submenu"><a href="#"><i class="icon icon-cog"></i> <span>系统设置</span></a>
            <ul>
                <!--<li><a href="${request.contextPath}/account/to-changePassword" class="sub_menu">修改密码</a></li>-->
                <li><a href="${request.contextPath}/system/module/list" class="sub_menu">功能模块</a></li>
                <li><a href="${request.contextPath}/account/logout">退出登录</a></li>
            </ul>
        </li>
    </ul>
</div>
<!--sidebar-menu-->

<!--main-container-part-->
<div id="content">
    <!--breadcrumbs-->
    <div id="content-header">
        <div id="breadcrumb"> <a href="${request.contextPath}/index" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> 首页</a></div>
        <h1 id="page-title"></h1>
    </div>
    <!--End-breadcrumbs-->

    <!--Action boxes-->
    <div class="container-fluid">
        <div class="quick-actions_homepage">
            <ul class="quick-actions">
                <li class="bg_lb span2"> <a href="${request.contextPath}/member/memberList"> <i class="icon-group"></i>会员管理</a> </li>
                <li class="bg_lg span2"> <a href="${request.contextPath}/product/infoList"> <i class="icon-th"></i> 商品管理</a> </li>
                <li class="bg_ly span3"> <a href="${request.contextPath}/stock/detail"> <i class="icon-circle-arrow-down"></i>商品入库</a> </li>
                <li class="bg_lo span3"> <a href="${request.contextPath}/sale/order/info"> <i class="icon-circle-arrow-up"></i>商品订单</a> </li>
            </ul>
        </div>

        <div class="row-fluid">
            <div class="widget-box">
                <div class="widget-title bg_lg"><span class="icon"><i class="icon-signal"></i></span>
                    <h5>日订单数据</h5>
                </div>
                <div class="widget-content" >
                    <div class="row-fluid">
                        <div class="span9">
                            <div class="chart"></div>
                        </div>
                        <div class="span3">
                            <ul class="site-stats">
                                <li class="bg_lh"><i class="icon-user"></i> <strong>${memberCount}</strong> <small>会员总数</small></li>
                                <li class="bg_lh"><i class="icon-plus"></i> <strong>${memberTodayCount}</strong> <small>今日新增</small></li>
                                <li class="bg_lh"><i class="icon-shopping-cart"></i> <strong>${salePrice?string("0.00")}</strong> <small>本周收入</small></li>
                                <li class="bg_lh"><i class="icon-tag"></i> <strong>${saleTodayPrice?string("0.00")}</strong> <small>今日收入</small></li>
                                <li class="bg_lh"><i class="icon-globe"></i> <strong>${productCount}</strong> <small>商品数量</small></li>
                                <li class="bg_lh"><i class="icon-repeat"></i> <strong>&nbsp;</strong> <small>刷新</small></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


</div>

<!--end-main-container-part-->

<!--Footer-part-->
<div class="row-fluid">
    <div id="footer" class="span12"> 2016 &copy; All Right </div>
</div>

<!--end-Footer-part-->

<!--<script src="${request.contextPath}/js/excanvas.min.js"></script>-->
<script src="${request.contextPath}/js/jquery-1.12.2.min.js"></script>
<script src="${request.contextPath}/js/jquery.ui.custom.js"></script>
<script src="${request.contextPath}/js/bootstrap.min.js"></script>
<script src="${request.contextPath}/js/jquery.flot.min.js"></script>
<script src="${request.contextPath}/js/jquery.flot.resize.min.js"></script>
<script src="${request.contextPath}/js/jquery.peity.min.js"></script>
<script src="${request.contextPath}/js/fullcalendar.min.js"></script>
<script src="${request.contextPath}/js/matrix.js"></script>
<!--<script src="${request.contextPath}/js/matrix.dashboard.js"></script>-->
<script src="${request.contextPath}/js/jquery.gritter.min.js"></script>
<!--<script src="${request.contextPath}/js/matrix.interface.js"></script>-->
<!--<script src="${request.contextPath}/js/matrix.chat.js"></script>-->

<!--<script src="${request.contextPath}/js/jquery.wizard.js"></script>-->
<!--<script src="${request.contextPath}/js/jquery.uniform.js"></script>-->
<!--<script src="${request.contextPath}/js/select2.full.min.js"></script>-->
<!--<script src="${request.contextPath}/js/matrix.popover.js"></script>-->
<!--<script src="${request.contextPath}/js/matrix.tables.js"></script>-->

<script type="text/javascript">

    $(function(){

        $(".quick-actions > li").click(function(){
            var url = $(this).children("a").attr("href");
            loadPage(url);
            return false;
        });

        $(".sub_menu").click(function(){
            var url = $(this).attr("href");
            loadPage(url);
            return false;
        });

        $("#btn_changePassword").click(function(){
            loadPage($(this).attr("href"));
            return false;
        });


        initModuleList();
    })
    // This function is called from the pop-up menus to transfer to
    // a different page. Ignore if the value returned is a null string:
    function goPage (newURL) {

        // if url is empty, skip the menu dividers and reset the menu selection to default
        if (newURL != "") {

            // if url is "-", it is this page -- reset the menu:
            if (newURL == "-" ) {
                resetMenu();
            }
            // else, send page to designated URL
            else {
                document.location.href = newURL;
            }
        }
    }

    // resets the menu selection upon entry to this page:
//    function resetMenu() {
//        document.gomenu.selector.selectedIndex = 2;
//    }

    var moduleList;
    var baseDir = "${request.contextPath}";
    function initModuleList(){
        $.post("${request.contextPath}/system/module/getModuleList", function(result){
            moduleList = result.data;
//            alert(moduleList);
        })
    }

    function siteMap(url){
        var href = url.indexOf("?") > -1 ? url.substring(0, url.indexOf("?")) : url;
//        console.log("href: " + href);
        var index = -1;
        var siteMap = new Array();
//        alert(moduleList);
        for(var i = 0; i < moduleList.length; i++){
            //寻找当前路径对应的module
//            console.log(moduleList[i].moduleHref);
            if (baseDir + moduleList[i].moduleHref == href){
                index = i;
//                console.log("index: " + i);
                siteMap.push(moduleList[i]);
                break;
            }
        }

        if (index > -1){
            var level = 0;
            var area = href;
            while (level < moduleList[index].level){
                area = area.lastIndexOf("/") > -1 ? area.substring(0, area.lastIndexOf("/")) : area;
//                console.log("level:" +  level + "; page: " + area );
                for(var i = index; i >= 0; i--){
                    if (baseDir + moduleList[i].moduleArea == area){
                        siteMap.push(moduleList[i]);
                        break;
                    }
                }
                level++;
            }
        }

        var breadcrumb = "<a href='${request.contextPath}/account/index'><i class='icon-home'></i> 首页</a>";
        for(var i = siteMap.length -1; i >= 0 ; i--){
            if (i == 0){
                //最后一个标签
                breadcrumb += "<a href='" + baseDir + siteMap[i].moduleHref + "' class='current'>" + siteMap[i].moduleName + "</a>";
                $("#page-title").html(siteMap[i].moduleName);
            }
            else{
                breadcrumb += "<a href='" + baseDir + siteMap[i].moduleHref + "'>" + siteMap[i].moduleName + "</a>";
            }
        }
        $("#breadcrumb").html(breadcrumb);
    }

    function loadPage(url, data){
        $(".container-fluid").html("");
        siteMap(url);
        $.ajax({
            url: url,
            data: data,
            type: "post",
            success: function(data, textStatus, xhr){
                $(".container-fluid").html(data);
            },
            error: function(xhr, textStatus, errorThrown){
//                alert(xhr.status);
                $.gritter.add({
                    title: xhr.status + " " + textStatus,
                    text: this.url + " " + errorThrown,
                    sticky: false
                });
            }
        });
    }
</script>
</body>
</html>
